<?php
include '../conn.php';
session_start();
$_GET["cookie"]=isset($_GET["cookie"])?$_GET["cookie"]:null;
if ($_GET["cookie"] == "out") {
    setcookie("cookie", "out",time()+3600,"/");
    $_SESSION = array();
    session_destroy();  //退出有错误
    echo "<script language=\"javascript\">location.href='../login.html';</script>";
}
if ($_COOKIE["cookie"] == "a-ok") {
    $id=$_SESSION["a-id"];
    $_SESSION["a-Year"];
    $sql = "select rank from administrator WHERE AdministratorId=$id";
    $result = mysqli_query($conn, $sql);
    $row = mysqli_fetch_array($result);
    $_SESSION["a-rank"] = $row[0];
    ?>

<?
} else {
    setcookie("cookie", "out",time()+3600,"/");
    ?>
    <script type="text/javascript">
        alert("你还未登录");
    </script>

    <?
    echo "<script language=\"javascript\">location.href='../login.html';</script>";
}
?>

